<template>
	<!-- 新增收货地址 -->
	<div id="Addaddress">
		<van-nav-bar @click-left="$router.go(-1)" fixed placeholder title="新增收货地址" left-arrow></van-nav-bar>
		<van-address-edit
			:area-list="areaList"
			show-postal
			show-set-default
			:area-columns-placeholder="['请选择', '请选择', '请选择']"
			@save="saveAddress"
		/>
	</div>
</template>

<script>
import { areaList } from '@vant/area-data';
	export default {
		data() {
			return {
				areaList
			}
		},
		methods:{
			saveAddress(content){
				delete content.country
				this.$store.dispatch("SaveUserAddress",content)
				.then(result => {
					if(result.code==0){
						this.$dialog.alert({
							message:"保存收货地址成功"
						})
						this.$router.go(-1)
					}else {
						this.$dialog.alert({
							message:"保存失败"
						})
					}
				}).catch(err=> this.$notify({
					type:"danger",
					message:"服务器异常"
				}))
			}
		},
		mounted(){
			
		}
	}
</script>

<style lang="scss" scoped>
@import "../../scss/GLOBAL.scss";
#Addaddress {
	user-select: none;
	::v-deep {
		.van-nav-bar {
			background-color: $themeColor;
			.van-nav-bar__title {
				color: #fff;
			}
			.van-icon {
				color: #fff;
			}
		}
		.van-icon {
			color: #fff;
		}
		.van-tag--danger{
			background-color: $themeColor;
		}
		.van-switch--on {
			background-color: $themeColor;
		}
	}
}
</style>